package com.freshdirect.src.model;

import java.util.Comparator;
import java.util.List;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;

public class Product {
    
    private int id;
    @NotEmpty(message = "Please enter product name.")
    @Size(min = 1, max = 45,message = "")
    private String name;
    @NotEmpty(message = "Please enter description.")
    @Size(min = 1, max = 1000,message = "")
    private String description;
    private int prodGroup;
    private double price;
    private int quantity;
    private int procurLevel;
    private int procurQuantity;
    @NotEmpty(message = "Please enter an image URL.")
    @Size(min = 1, max = 100,message = "")
    private String image;
    private List<Integer> supplierIDs;
    private String supplierName;

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public List<Integer> getSupplierIDs() {
        return this.supplierIDs;
    }
    
    public String getSupsIntoString(){
        String sups = "";
        for (Integer supplierID : supplierIDs) {
            sups += supplierID + ",";
        }
        return sups;      
    }

    public void setSupplierIDs(List<Integer> supplierIDs) {
        this.supplierIDs = supplierIDs;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getProdGroup() {
        return prodGroup;
    }

    public void setProdGroup(int prodGroup) {
        this.prodGroup = prodGroup;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
    
    public String getImage() {
        return image;
    }
    
    public void setImage(String image) {
        this.image = image;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public int getProcurLevel() {
        return procurLevel;
    }

    public void setProcurLevel(int procurLevel) {
        this.procurLevel = procurLevel;
    }

    public int getProcurQuantity() {
        return procurQuantity;
    }

    public void setProcurQuantity(int procurQuantity) {
        this.procurQuantity = procurQuantity;
    }
    
    /*Comparator for sorting the list by Product Name*/
    public static Comparator<Product> NameComparator = new Comparator<Product>() {

	public int compare(Product p1, Product p2) {
	   String ProductName1 = p1.getName().toUpperCase();
	   String ProductName2 = p2.getName().toUpperCase();

	   //ascending order
	   return ProductName1.compareTo(ProductName2);

	   //descending order
	   //return StudentName2.compareTo(StudentName1);
    }};

    /*Comparator for sorting the list by roll no*/
    public static Comparator<Product> Price = new Comparator<Product>() {

	public int compare(Product p1, Product p2) {

	   double price1 = p1.getPrice();
	   double price2 = p2.getPrice();
	   /*For ascending order*/
           return Double.compare(price1, price2);

	   /*For descending order*/
	   //rollno2-rollno1;
   }};
    
     /*Comparator for sorting the list by Product Name*/
    public static Comparator<Product> SupplierName = new Comparator<Product>() {

	public int compare(Product p1, Product p2) {
	   String SupplierName1 = p1.getSupplierName().toUpperCase();
	   String SupplierName2 = p2.getSupplierName().toUpperCase();

	   //ascending order
	   return SupplierName1.compareTo(SupplierName2);

	   //descending order
	   //return StudentName2.compareTo(StudentName1);
    }};
    

}
